<?php

namespace app\admin\controller;

use app\common\business\AdminRole;
use app\common\lib\Param;
use app\common\lib\Show;
use think\response\Json;

class FeedBack extends AdminBase
{
    /**
     * 意见反馈列表
     * @return Json
     */
    public function list(): Json
    {
        list($keyword, $page,$limit) = Param::getMore([
            ['keyword', ''],
            ['page', 0],
            ['limit', 0],
        ], $this->request, true);

        $feedBackBis = new \app\common\business\FeedBack();

        $data = [
            'keyword'=>$keyword
        ];
        try {
            $result=$feedBackBis->getJoinPageList($data,$page,$limit);
        }catch (\Exception $e){
            return Show::error([], $e->getMessage(), $e->getCode());
        }

        $result['list'] = $feedBackBis->resetInfo($result['list']);
        return Show::success($result);
    }

    /**
     * 根据id删除
     * @return Json
     */
    public function deleteById(): Json
    {
        $id=$this->request->get('id');
        try {
            $result=(new \app\common\business\FeedBack())->deleteById($id);
        }catch (\Exception $e){
            return Show::error([], $e->getMessage(), $e->getCode());
        }
        if ($result) {
            return Show::success([], "删除成功");
        }
        return Show::error([], '删除失败');
    }
}
